{include file='Public/header' /}
<div class="layui-layout layui-layout-admin">
{include file='Public/head' /}	
{include file='Public/side' /}	
	<div class="layui-body"> 
{include file='Public/crumbs' /}
		<!-- 内容主体区域 -->
		<div class="shu-body">
			<div class="layui-fluid">
				<form class="layui-form layui-form-pane" action="" method="post">
				<input type="hidden" name="pid" id="pid" value="{$pid}">
                <input type="hidden" name="aid" value="{notempty name='article'}{$article.aid}{/notempty}" id="aid"/>
				<div class="layui-form-item">
					<label class="layui-form-label">文章分类</label>
				  	<div class="layui-input-inline">
					<select id="sid" name="sid">
						{if condition="!$pid"}
						<option value="0">--分类--</option>
						{/if}
						{$category}
                    </select>
				    </div>
					<div class="layui-form-mid layui-word-aux">请仔细选择分类</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">文章标题</label>
				  	<div class="layui-input-block">
						<input type="text" name="title" id="title" placeholder="文章标题" class="layui-input" value="{notempty name='article'}{$article['title']}{/notempty}" required  lay-verify="required" autocomplete="off">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">SEO标题</label>
				  	<div class="layui-input-inline">
					<input type="text" name="seotitle" id="seotitle" placeholder="SEO标题" class="layui-input" value="{notempty name='article'}{$article['seotitle']}{/notempty}">
				  	</div>
					<div class="layui-form-mid layui-word-aux">如果设置SEO标题，将会在IE标题栏显示SEO标题</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">关键词</label>
				  	<div class="layui-input-inline">
					<input type="text" name="keywords" id="keywords" placeholder="关键词" class="layui-input" value="{notempty name='article'}{$article['keywords']}{/notempty}">
				  	</div>
					<div class="layui-form-mid layui-word-aux">文章关键词</div>
				</div>
				<div class="layui-form-item layui-form-text">
				  	<label class="layui-form-label">文章摘要</label>
				  	<div class="layui-input-block">
					<textarea name="description" id="description" placeholder="文章摘要" class="layui-textarea">{notempty name='article'}{$article['description']}{/notempty}</textarea>
				  	</div>
					<div class="layui-form-mid layui-word-aux">文章摘要、描述。</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">排序</label>
				  	<div class="layui-input-inline">
					<input type="text" name="o" id="o" placeholder="排序" class="layui-input" value="{notempty name='article'}{$article['o']}{/notempty}">
				  	</div>
					<div class="layui-form-mid layui-word-aux">数字越大越靠前</div>
				</div>
				
				
				<div class="layui-form-item">
				  	<label class="layui-form-label" style="height:100px; line-height:80px;">缩略图</label>
				  	<div class="layui-input-inline">
					{notempty name='article'}
                                    {:UpImage("thumbnail",100,100,$article['thumbnail'])}
									{else /}
									{:UpImage("thumbnail",100,100,null)}
					{/notempty}
				  	</div>
					<div class="layui-form-mid layui-word-aux" style="line-height:80px">仅支持jpg、gif、png、bmp、jpeg，且小于1MB。</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">日期</label>
				  	<div class="layui-input-block">
					{notempty name='article'}
						<input class="layui-input" id="t" name="t" value="{notempty name='article'}{$article['t']|date=" Y-m-d",###}{/notempty}" type="text"/>
					{else /}
					<input class="layui-input" id="t" name="t" value="{$ttt|date=" Y-m-d",###}" type="text" />
					{/notempty}
				 	</div>
				</div>
				<div class="layui-form-item layui-form-text">
				  	<label class="layui-form-label">文章内容</label>
				  	<div class="layui-input-block">
					<textarea style="height:300px;" name="content" id="content" placeholder="文章内容" class="layui-textarea">{notempty name='article'}{$article['content']}{/notempty}</textarea>
				  	</div>
				</div>
				
				
				<div class="layui-form-item">
				  <div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				  </div>
				</div>
			  </form>
			</div>
		</div>
		<!-- 内容主体区域 END-->
	</div>
{include file='Public/footer' /}	
<script>
layui.use(['form','layer','laydate'], function(){
	var form = layui.form,jq = layui.jquery,layer=layui.layer,laydate = layui.laydate;
	//日期
	laydate.render({
    	elem: '#t' //指定元素
  	});
	
	form.on('submit(formDemo)', function(data){
		loading = layer.load(2, {
			shade: [0.2,'#000']
		});
		var param = data.field;
		jq.post("{:url('update')}",param,function(data){
			//console.log(data);
			if(data.code == 1){
				layer.close(loading);
				layer.msg(data.msg, {icon: 1, time: 1000}, function(){
					//location.reload();
					location.href=data.url;
				});
			}else{
				layer.close(loading);
				layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			}
		});
	return false;
	});
	
	////编辑器
	var editor = new wangEditor('content');
	editor.config.uploadImgUrl = "{:url('Upload/picupdate')}";
	editor.config.uploadImgFileName = 'FileName';
	editor.config.menus = $.map(wangEditor.config.menus, function(item, key) {
//	if (item === 'img') {  //屏蔽图片
//	return null;
//	}
	if (item === 'eraser') {
	return null;
	}
	if (item === 'video') {
	return null;
	}
	if (item === 'location') {
	return null;
	}
	return item;
	});
	editor.config.pasteText = true;
	editor.create();
	
});
</script>